<template>
    <div id='tmpl'>
        <!--1.0 实现新闻资讯列表样式-->
        <ul class="mui-table-view">
				<li v-for='item in list' class="mui-table-view-cell mui-media">
					<router-link v-bind='{to:"/news/newsinfo/"+item.id}'>
						<img class="mui-media-object mui-pull-left" :src="item.img_url">
						<div class="mui-media-body">
							{{item.title}}
							<p class='mui-ellipsis'>{{item.zhaiyao}}</p>
						</div>
                        <div class="time_count">
                            <span>发表时间:{{item.add_time | datafmt('YYYY-MM-DD HH:mm:ss')}}</span>
                            <span class="lastspan">点击数:{{item.click}}</span>
                        </div>
					</router-link>
				</li>
			</ul>
    </div>
</template>
<script>
export default {
    data() {
        return {
            list:[]
        }
    },
    created(){
        this.getnewslist();
    },
    methods:{
        // 获取api中新闻资讯数据
        getnewslist:function(){
            var url = this.$common.apidomain+'/api/getnewslist';
            this.$http.get(url).then(function(response){
                var data = response.body;
            //判断数据中的状态值,status=0表示成功,非零表示请求失败
            if(data.status !== 0){
                this.$tip(data.message)
                return;
            }
            this.list = data.message;

            })
        }
    }
}
</script>
<style scoped>
    .mui-table-view img{
        width: 80px;
        height: 80px;
        max-width: 80px;
    }
    .time_count{
        color:#26a2ff;
        margin-top:2em;
        font-size:14px;
    }
    .time_count .lastspan{
        margin-left: 20px;
    }
</style>